var onsale = false;

$(function() {
	mobileGlobal.sendRequest(__mobilectx + "/cybercafe/good/loadViewDetailData.xhtml", {goodid : __goodId}, null, function(data, status) {
		mobileGlobal.hideLoading();
		if (data.status) {
			var swiperWrapper = $(".swiper-container > .swiper-wrapper");
			for (var i = 0; i < data.result.goodpics.length; i ++) {
				swiperWrapper.append("<div class='swiper-slide'><img src='" + data.result.goodpics[i] + "' alt=''></div>");
			}
			$(".swiper-container").swiper({ loop: true, autoplay: 3000 });
			
			var textContainerItem = $(".content").children(".text-container").children(".text-container-item");
			textContainerItem.children(".name").text("【" + data.result.goodcode + "】" + data.result.goodname);
			textContainerItem.children(".specs").text(data.result.goodspecs);
			textContainerItem.children(".price").removeClass("hidden");
			textContainerItem.children(".price").children("span:eq(0)").text(data.result.goodprice.toFixed(2));
			textContainerItem.children(".price").children("span:eq(1)").text(data.result.meteringunit);
			textContainerItem.children(".manufacturer").text(data.result.manufacturer);
			textContainerItem.children(".detail").text(data.result.gooddetail);
			
			onsale = true;
		} else mobileGlobal.failed(data.result);
	});
});

//返回按钮点击事件
function onBackClick() {
	mobileGlobal.backword();
}

//购买按钮点击事件
function onBuyClick() {
	if (!onsale) return;
	addToCart(__goodId);
}